﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

namespace Team4Mock.UserControl.TrustDistrict
{
    public partial class ViewAll : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (!string.IsNullOrEmpty(Convert.ToString(Session["role"])))
                {
                    if (Session["role"].ToString().Equals("Admin"))
                    {
                        if (!string.IsNullOrEmpty(Convert.ToString(Request.QueryString["ID"])))
                        {
                            pnView.Visible = false;
                            pnct.Visible = true;
                        }
                        else
                        {
                            pnView.Visible = true;
                            pnct.Visible = false;
                            LoadGV();
                        }
                    }
                    else
                    {
                        //Quang thong bao
                    }
                }
                else
                {
                    Response.Redirect("/FormView/Login.aspx");
                }
            }
        }
        protected void btnCreate_Click(object sender, EventArgs e)
        {
            pnct.Visible = true;
            pnView.Visible = false;
        }
        void LoadGV()
        {
            DataTable dt = new DataTable();
            dt.Columns.Add("ID", typeof(int));
            dt.Columns.Add("District Name");
            dt.Columns.Add("Description");
            dt.Columns.Add("Region");
            dt.Columns.Add("Is Active");

            dt.Rows.Add(1, "New District", "Description 1", "Region 1", "Yes");
            dt.Rows.Add(1, "New District", "Description 1", "Region 1", "Yes");
            dt.Rows.Add(1, "New District", "Description 1", "Region 1", "Yes");
            dt.Rows.Add(1, "New District", "Description 1", "Region 1", "Yes");
            gvTrusDistrict.DataSource = dt;
            gvTrusDistrict.DataBind();
        }
    }
}